package thread.demo07.ExecutorService;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 改进版
 * 
 * @author mengzhang6
 *
 */
public class ThreadPoolDemo3 {
	public static void main(String[] args) {

		ThreadPoolExecutor pool = new ThreadPoolExecutor(2, 2, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(10),
				Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

		for (int i = 0; i < 10; i++) {
			int index = i;
			pool.submit(() -> System.out.println("i:" + index + " executorService"));
		}
		pool.shutdown();
	}
}
